<include file="../Public/_header.html" />
<div class="so_main">
  <!-------- 搜索用户 -------->
  <!-------- 搜索开始 -------->
		  <div id="search_div">
		  	<div class="page_tit">
		  		搜索用户 [ <a href="javascript:void(0);" onclick="_show_searcharea();">隐藏</a> ]
		  	</div>
		
				<div class="sform">
					<form method="post" action="{:U('/User/doSearchUser')}">
						<input id="pno" name="pno" type="hidden" value="1">
						<input name="type" type="hidden" value="search">
							
					    <dl>
					      	<span>Email：</span>
					        	<input name="email" id="email" type="text" value="{$email}" title="用户进行登录的帐号,多个时使用英文的","分割">

					      	<span>用户ID：</span>
		 						<input name="uid" id="uid" type="text" value="{$uid}" title="用户ID,多个时使用英文的","分割">
 							
 							<span>姓名：</span>
 							 	<input name="uname" id="uname" type="text" value="{$uname}" title="用户姓名模糊查询,多个时使用英文的","分割">
        				</dl>	
        						
        						
        				<dl>
					      	<span>性别：</span>
						      	<input name="gender" type="radio" value="" <eq name="gender" value="">checked</eq>>全部
						        <input name="gender" type="radio" value="M" <eq name="gender" value="M">checked</eq>>男
						        <input name="gender" type="radio" value="F" <eq name="gender" value="F">checked</eq>>女
					  
					      <span>是否激活：</span>
					      	<input name="is_active" type="radio" value="" <eq name="is_active" value="">checked</eq>>全部
					        <input name="is_active" type="radio" value="1" <eq name="is_active" value="1">checked</eq>>是
					        <input name="is_active" type="radio" value="0" <eq name="is_active" value="0">checked</eq>>否
					  	</dl>	
        						
        						
        				<dl>
					    	<input type="submit" class="btn_b" value="提交" />
					    	&nbsp;&nbsp;&nbsp;
					    	<input type="reset" class="btn_b" value="清空" />
					    </dl>
					</form>
			  </div>
		  </div>
		 
  
  <!-------- 用户列表 -------->
  <div class="page_tit">用户管理</div>
  <div class="Toolbar_inbox">
  	<div class="page right">{$html}</div>
	<a href="{:U('/User/addUser')}" class="btn_a"><span>添加用户</span></a>
	<a href="javascript:void(0);" class="btn_a" onclick="_show_searcharea();">
		<span class="searchUser_action">搜索用户</span>
	</a>
	<a href="javascript:void(0);" class="btn_a" onclick="deleteUser();"><span>删除用户</span></a>
  </div>
  <div class="list">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <th style="width:30px;">
		<input type="checkbox" id="checkbox_handle" onclick="table_checkAll(this)" value="0">
    	<label for="checkbox"></label>
	</th>
    <th class="line_l" style="text-align:center;">ID</th>
    <th class="line_l" style="text-align:center;">公开/有效</th>
    <th class="line_l">用户信息</th>
    <th class="line_l" style="text-align:center;">姓名</th>
    <th class="line_l" style="text-align:center;">生日</th>
    <th class="line_l">地区</th>
    <th class="line_l" style="text-align:center;">绑定手机</th>
    <th class="line_l" style="text-align:center;">绑定账号</th>
    <th class="line_l" style="text-align:center;">注册时间</th>
    <th class="line_l" style="text-align:center;">状态</th>
    <th class="line_l" style="text-align:center;">操作</th>
  </tr>
  <volist id="vo" name="data">
  	  <php>$loginbinds = model('User')->syncStatus($vo['id']);</php>
	  <tr overstyle='on' id="user_{$vo['id']}">
	    <td><input type="checkbox" name="checkbox" id="checkbox2" onclick="table_checkon(this)" value="{$vo.uid}"></td>
	    <td style="text-align:center;">{$vo.id}</td>
	    <td style="text-align:center;">{$vo.is_open}&nbsp;&nbsp;/&nbsp;&nbsp;{$vo.enable}</td>
	    <td>
			<div style="float:left;margin-right:10px;border:1px solid #8098A8;height:30px;padding:1px;width:30px;""><img src="{$vo.id|getUserFace='s'}" width="30"></div>
			<div style="float:left">【<eq name="vo.gender" value="M">男</eq><eq name="vo.gender" value="F">女</eq>】{$vo.uname}<br>{$vo.email}</div></td>
		<td style="text-align:center;">{$vo['realname']}</td>
		<td style="text-align:center;">{:paramMillisecond2Date($vo['btime'],'Y-m-d','')}</td>
	    <td>
			{:getAreaDesc($vo['province_id'],$vo['city_id'],$vo['area_id'])}
		</td>
		<td style="text-align:center;">{$vo['mobile']}</td>
		<td style="text-align:center;">
								<php>if($loginbinds['sina']!=null){</php>
									<img src="/Public/Images/global/sina24x24.png" align="absmiddle" title="已绑定新浪微博">
								<php>}</php>
								<php>if($loginbinds['douban']!=null){</php>
									<img src="/Public/Images/global/douban24x24.png" align="absmiddle" title="已绑定豆瓣">
								<php>}</php>
		</td>
	    <td style="text-align:center;">{$vo.ctime|date="Y-m-d H:i",###}</td>
	    <td style="text-align:center;"><eq name="vo['is_active']" value="0">未激活<else/>激活</else></eq></td>
	    <td style="text-align:center;">
			<!--<a href="javascript:void(0);" onclick="changeDepartment({$vo['uid']});">转移部门</a>-->
			<a href="#" title="登陆纪录">记录</a>
			&nbsp;&nbsp;
			<a href="{:U('/User/editUser', array('uid'=>$vo['uid']))}">编辑</a>
			&nbsp;&nbsp;
	    	<a href="javascript:void(0);" onclick="deleteUser({$vo['uid']});">删除</a>
		</td>
	  </tr>
  </volist>
  </table>
  </div>
  
  <div class="Toolbar_inbox">
	<div class="page right">{$html}</div>
	<a href="{:U('/User/addUser')}" class="btn_a"><span>添加用户</span></a>
	<a href="javascript:void(0);" class="btn_a" onclick="_show_searcharea();">
		<span class="searchUser_action">搜索用户</span>
	</a>
	<a href="javascript:void(0);" class="btn_a" onclick="deleteUser();"><span>删除用户</span></a>
  </div>
</div>

<script>
	//鼠标移动表格效果
	$(document).ready(function(){
		$("tr[overstyle='on']").hover(
		  function () {
		    $(this).addClass("bg_hover");
		  },
		  function () {
		    $(this).removeClass("bg_hover");
		  }
		);
	});
	
	function checkon(o){
		if( o.checked == true ){
			$(o).parents('tr').addClass('bg_on') ;
		}else{
			$(o).parents('tr').removeClass('bg_on') ;
		}
	}
	
	function checkAll(o){
		if( o.checked == true ){
			$('input[name="checkbox"]').attr('checked','true');
			$('tr[overstyle="on"]').addClass("bg_on");
		}else{
			$('input[name="checkbox"]').removeAttr('checked');
			$('tr[overstyle="on"]').removeClass("bg_on");
		}
	}

	//获取已选择用户的ID数组
	function getChecked() {
		var uids = new Array();
		$.each($('table input:checked'), function(i, n){
			uids.push( $(n).val() );
		});
		return uids;
	}

	//转移部门
	function changeDepartment(uids) {
		var uids = uids ? uids : getChecked();
		uids = uids.toString();
		if(!uids) {
			ui.error('请先选择用户');
			return false;
		}

		if(!confirm('转移成功后，已选择用户原来的部门信息将被覆盖，确定继续？')) return false;
		
		ui.box.load("{:U('/User/changeDepartment')}&uids="+uids, {title:'转移部门'});
	}
	
	//转移用户组
	function changeUserGroup(uids) {
		var uids = uids ? uids : getChecked();
		uids = uids.toString();
		if(!uids) {
			ui.error('请先选择用户');
			return false;
		}

		if(!confirm('转移成功后，已选择用户原来的用户组信息将被覆盖，确定继续？')) return false;
		
		ui.box.load("{:U('/User/changeUserGroup')}&uids="+uids, {title:'转移用户组'});
	}
	
	//删除用户
	function deleteUser(uid) {
		uid = uid ? uid : getChecked();
		uid = uid.toString();
		if(uid == '' || !confirm('删除成功后将无法恢复，确认继续？')) return false;
		
		$.post("{:U('/User/doDeleteUser')}", {uid:uid}, function(res){
			if(res == '1') {
				uid = uid.split(',');
				for(i = 0; i < uid.length; i++) {
					$('#user_'+uid[i]).remove();
				}
				ui.success('保存成功');
			}else {
				ui.error('保存失败');
			}
		});
	}
	
</script>

<include file="../Public/_footer.html" />